<include file="Public/min-header"/>
<div class="wrapper">
 <include file="Public/breadcrumb"/>
 <style>#search-form > .form-group{margin-left: 10px;}</style>
  <!-- Main content -->
  <section class="content">
    <div class="container-fluid">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title"><i class="fa fa-list"></i> 商品列表</h3>
        </div>
        <div class="panel-body">
          <div class="navbar">
              <form action="" id="search-form2" class="navbar-form form-inline" style="padding: 0;" method="post" onsubmit="return false">
                
             
                <div class="form-group">
                  <label class="control-label" for="input-order-id" style="padding: 0 10px;">关键词</label>
                  <div class="input-group">
                    <input type="text" name="key_word" value="" placeholder="搜索词" id="input-order-id" class="form-control">
                  </div>
                </div>                  
                <!--排序规则-->
                <button type="submit" onclick="ajax_get_table('search-form2',1)" id="button-filter search-order" class="btn btn-primary"><i class="fa fa-search"></i> 筛选</button>
              
              </form>
          </div>
          <div id="ajax_return"> </div>
        </div>
      </div>
    </div>
    <!-- /.row --> 
  </section>
  <!-- /.content --> 
</div>
<!-- /.content-wrapper --> 
<script>
    $(document).ready(function(){
		// ajax 加载商品列表
        ajax_get_table('search-form2',1);

    });


    // ajax 抓取页面 form 为表单id  page 为当前第几页
    function ajax_get_table(form,page){
		cur_page = page; //当前页面 保存为全局变量
            $.ajax({
                type : "POST",
                url:"/index.php?m=Seller&c=goods&a=ajaxpromGoodsList&p="+page,//+tab,
                data : $('#'+form).serialize(),// 你的formid
                success: function(data){
                    $("#ajax_return").html('');
                    $("#ajax_return").append(data);
                }
            });
        }
      
        // 点击排序
        function sort(field)
        {
           $("input[name='orderby1']").val(field);
           var v = $("input[name='orderby2']").val() == 'desc' ? 'asc' : 'desc';             
           $("input[name='orderby2']").val(v);
           ajax_get_table('search-form2',cur_page);
        }
        
        // 删除操作
        function del(id)
        {
            if(!confirm('确定要删除吗?'))
                return false;
		$.ajax({
			url:"/index.php?m=Seller&c=goods&a=delGoods&id="+id,
			success: function(v){	
                                var v =  eval('('+v+')');                                 
                                if(v.hasOwnProperty('status') && (v.status == 1))
                                        ajax_get_table('search-form2',cur_page);                                                      
                                else
                                        layer.msg(v.msg, {icon: 2,time: 1000}); //alert(v.msg);
			}
		}); 
               return false;
        }

        // 加入回收站
        function doneTrash(id)
        {
            if(!confirm('确定要加入回收站吗?'))
                return false;
			$.ajax({
				url:"/index.php?m=Seller&c=goods&a=doneTrash&id="+id,
				success: function(v){	
									var v =  eval('('+v+')');                                 
									if(v.hasOwnProperty('status') && (v.status == 1))
											ajax_get_table('search-form2',cur_page);                                                      
									else
											layer.msg(v.msg, {icon: 2,time: 1000}); //alert(v.msg);
				}
			}); 
               return false;
        }
        // 恢复
        function rollback(id)
        {

			$.ajax({
				url:"/index.php?m=Seller&c=goods&a=rollBack&id="+id,
				success: function(v){	
									var v =  eval('('+v+')');                                 
									if(v.hasOwnProperty('status') && (v.status == 1))
											ajax_get_table('search-form2',cur_page);                                                      
									else
											layer.msg(v.msg, {icon: 2,time: 1000}); //alert(v.msg);
				}
			}); 
               return false;
        }

    $("#batch").click(function(){
        var myrul='/index.php/Seller/Goods/batch_add';//+myrel;
        layer.open({
            type: 2,
            shadeClose: true, //点击遮罩关闭
            title:'批量导入商品',
            skin: 'layui-layer-rim', //加上边框
            area: ['920px', '620px'], //宽高
            content: myrul
        });
    });


    $("#edit_price").click(function(){
        var myrul='/index.php/Seller/Goods/batch_edit_price';//+myrel;
        layer.open({
            type: 2,
            shadeClose: true, //点击遮罩关闭
            title:'批量修改价格/库存',
            skin: 'layui-layer-rim', //加上边框
            area: ['1500px', '800px'], //宽高
            content: myrul
        });
    });
</script> 
</body>
</html>